package com.frogs.ucenter.v1.request;

import javax.servlet.http.HttpServletRequest;

import com.frogs.framework.util.StringUtil;
import com.frogs.framework.web.HttpRequestInfo;
import com.frogs.system.util.ApiUrlParamEnum;
import com.frogs.system.web.api.request.Request;
import com.frogs.system.web.exception.RequestIllegalException;

/**
 * 添加用户开发平台信息请求参数类
 *
 * @author lijian
 * @version 2014年3月23日 - 下午2:31:21
 */
public class UserOpenPlatformInfoAddRequest extends Request{

	/**
	 * 账号ID
	 */
	private int userId;
	
	/**
	 * 开放平台ID<br>
	 * 1：微信
	 * 2：qq
	 * 3：微博
	 */
	private int openPlatformId;
	
	/**
	 * 开放平台token
	 */
	private String openToken;
	
	/**
	 * 网站上唯一对应用户身份的标识
	 */
	private String openId;
	
	/** */
	public UserOpenPlatformInfoAddRequest() {
	}
	
	@Override
	public void parse(HttpServletRequest request) {
		
		HttpRequestInfo requestInfo = new HttpRequestInfo(request);
		
		this.userId = requestInfo.getIntParameter(ApiUrlParamEnum.userId.getParamName(), 0);
		this.openPlatformId = requestInfo.getIntParameter(ApiUrlParamEnum.openPlatformId.getParamName(), 0);
		this.openToken = requestInfo.getParameter(ApiUrlParamEnum.openToken.getParamName(), "");
		this.openId = requestInfo.getParameter(ApiUrlParamEnum.openId.getParamName(), "");
		if ( userId < 1 ) {
			throw new RequestIllegalException("error userId: " + userId);
		}
		if ( openPlatformId < 1 ) {
			throw new RequestIllegalException("error openPlatformId: " + openPlatformId);
		}
		if ( StringUtil.isEmpty(openToken)) {
			throw new RequestIllegalException("error openToken: " + openToken);
		}
		if ( StringUtil.isEmpty(openId)) {
			throw new RequestIllegalException("error openId: " + openId);
		}
	}

	public int getUserId() {
		return userId;
	}

	public void setUserId(int userId) {
		this.userId = userId;
	}

	public int getOpenPlatformId() {
		return openPlatformId;
	}

	public void setOpenPlatformId(int openPlatformId) {
		this.openPlatformId = openPlatformId;
	}

	public String getOpenToken() {
		return openToken;
	}

	public void setOpenToken(String openToken) {
		this.openToken = openToken;
	}

	public String getOpenId() {
		return openId;
	}

	public void setOpenId(String openId) {
		this.openId = openId;
	}

}
